#ifndef _THREADPOOL_H_
#define _THREADPOOL_H_

#include "queuetask.h"
#include <semaphore.h>
#include <pthread.h>
#include <unistd.h>

struct thread_pool{
    sem_t semr;
    sem_t semw;
    pthread_mutex_t mutex;
    struct queuetask *que;

    int threads;//线程个数
    int max_que_len;//队列最大长度
    pthread_t *tids;//线程个数
};

//创建线程池
struct thread_pool *create_threadpool(int threads,int max_que_len,void *(*fun)(void *));

//销毁线程池
void destroy_threadpool(struct thread_pool *pool);

#endif
